/**
 * 初始化质控项目表详情对话框
 */
var SdsQcentityItemInfoDlg = {
    validateFields: {
    	btCode: {
            validators: {
                notEmpty: {
                    message: '质控项目代码不能为空'
                }
            }
        },
    	btDesc: {
            validators: {
                notEmpty: {
                    message: '质控项目名称不能为空'
                }
            }
        },
    	btUpType: {
            validators: {
                notEmpty: {
                    message: '上传类型不能为空'
                }
            }
        },
    	btIsActive: {
            validators: {
                notEmpty: {
                    message: '有效标志不能为空'
                }
            }
        },
    	btIsNeeded: {
            validators: {
                notEmpty: {
                    message: '是否必填不能为空'
                }
            }
        },
    	formItemCode: {
            validators: {
                notEmpty: {
                    message: '关联表单项目代码不能为空'
                }
            }
        }
    }
};


/**
 * 关闭此对话框
 */
SdsQcentityItemInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
SdsQcentityItemInfoDlg.validate = function () {
    $('#sdsQcentityItemInfoForm').data("bootstrapValidator").resetForm();
    $('#sdsQcentityItemInfoForm').bootstrapValidator('validate');
    return $("#sdsQcentityItemInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
SdsQcentityItemInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityItemInfoForm',Sys.backendPath + "/sds/sdsqcentityitem/add",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentityItem.table.refresh();
        SdsQcentityItemInfoDlg.close();
    });
}

/**
 * 审核
 */
SdsQcentityItemInfoDlg.reviewUpdates = function(){
    var ajax = new $ax(Sys.backendPath + "/sds/sdsqcentityitem/resetUpdateFlag",function (res){
        Sys.info("审核成功！")
        window.parent.SdsQcentityItem.table.refresh();
        SdsQcentityItemInfoDlg.close();
    }, function (res){
        Sys.info("审核失败！")
    });
    ajax.set("id",$("#id").val());
    ajax.start();
}

/**
 * 提交修改
 */
SdsQcentityItemInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityItemInfoForm',Sys.backendPath + "/sds/sdsqcentityitem/update",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentityItem.table.refresh();
        SdsQcentityItemInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("sdsQcentityItemInfoForm", SdsQcentityItemInfoDlg.validateFields);
});
